<template>
    <div class="loading" v-loading="loading" element-loading-text="登录中" element-loading-spinner="el-icon-loading" element-loading-background="rgba(0, 0, 0, 0.8)"></div>
</template>

<script>
import { postAdminPricingSetNologin_web } from "@/api";
import { setStore } from "@/utils/localStorage.js";
export default {
    data() {
        return {
            loading: true,
        };
    },
    mounted() {
        const _GetUrlKey = (name) => {
            const reg = new RegExp(`[?|&]${name}=([^&;]+?)(&|#|;|$)`);
            const { href } = window.location;
            return (
                (reg &&
                    decodeURIComponent(
                        (reg.exec(href) || ["", ""])[1].replace(/\+/g, "%20")
                    )) ||
                null
            );
        };
        let obj = {
            code: _GetUrlKey("code"),
            is_subject:'mz'
        };
        postAdminPricingSetNologin_web(obj)
            .then((res) => {
                setStore("userinfo", res.data);
                this.$store.commit("mutationsNavMenuList", res.data.roletop);
                let qxobj = {};
                let qx = res.data.roletop[0].list[0].qx;
                qx.forEach((element) => {
                    qxobj[element.rolekey] = 1;
                });
                qxobj = JSON.stringify(qxobj);
                this.$router.push({
                    name: res.data.roletop[0].list[0].unique,
                    query: { qxobj },
                });
                this.loading = false;
            })
            .catch((err) => {
                let data = JSON.stringify(err);
                alert("err" + data + "code:" + code);
                this.$router.go(-1);
            });
    },
};
</script>

<style lang="scss" scoped>
.loading {
    width: 100vw;
    height: 100vh;
}
</style>
